// pages/caseDesc/caseDesc.js
const app = getApp()
var postLogin = require("../../utils/wh.js");
var WxParse = require('../../wxParse/wxParse.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    caseID:"",
    list:[],
  },
 /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      caseID: options.id
    })
    wx.showLoading({
      title: '加载中•••',
      // mask: true
    })
    this.loop();
  },
  loop: function () {
    var that = this;
    var code = app.globalData.code;
    if (!code) {
      var that = this
      setTimeout(function () { that.loop(); }, 100) 
    } else {
      that.setData({
        code: code,
      })
      var postUrl = '/api/company.index/caseContent',
        postData = {
          case_id: that.data.caseID
        };
      postLogin.Post(postUrl, postData, that.caseDetails);
    }
  },
  caseDetails: function (res) {
    let that = this;
    var list = res;
    wx.hideLoading();
    var article = res.case_content;
    WxParse.wxParse('article', 'html', article, this);
    that.setData({
      list: list,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})